package com.nc.delivery_project.server.domain;

import java.util.Date;
import java.util.List;

public class Order {

    private Long id;

    private User sender;
    private User reciever;

    private String startDate;
    private String deliveryDate;

    private String comment;

    private String status;

    private List<Cargo> cargoes;

    private Payment payment;

    private List<OrderWaypoint> orderWaypoints;

    public Order(){}
    public Order(Long id, User sender, User reciever, String startDate, String deliveryDate, String comment, String status, Payment payment)
    {
        this.id=id;
        this.sender=sender;
        this.reciever=reciever;
        this.startDate=startDate;
        this.deliveryDate=deliveryDate;
        this.comment=comment;
        this.status=status;
        this.payment=payment;
    }
    public Order(Long id, User sender, User reciever, String startDate, String deliveryDate, String comment, String status,
                 List<Cargo> cargoes, Payment payment, List<OrderWaypoint> orderWaypoints)
    {
        this(id,sender,reciever,startDate,deliveryDate,comment,status,payment);
        this.cargoes=cargoes;
        this.orderWaypoints=orderWaypoints;
    }

    public int getId() {
        return id.intValue();
    }

    public void setId(Long id) {
        this.id = id;
    }

    public User getSender() {
        return sender;
    }

    public void setSender(User sender) {
        this.sender = sender;
    }

    public User getReceiver() {
        return reciever;
    }

    public void setReceiver(User receiver) {
        this.reciever = receiver;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public String getDeliveryDate() {
        return deliveryDate;
    }

    public void setDeliveryDate(String deliveryDate) {
        this.deliveryDate = deliveryDate;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public List<Cargo> getCargoes() {
        return cargoes;
    }

    public void setCargoes(List<Cargo> cargoes) {
        this.cargoes = cargoes;
    }

    public Payment getPayment() {
        return payment;
    }

    public void setPayment(Payment payment) {
        this.payment = payment;
    }
    public List<OrderWaypoint> getOrderWaypoints()
    {
        return orderWaypoints;
    }
    public void setOrderWaypoints(List<OrderWaypoint> orderWaypoints)
    {
        this.orderWaypoints=orderWaypoints;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Order)) return false;

        Order order = (Order) o;

        if (sender != null ? !sender.equals(order.sender) : order.sender != null) return false;
        if (reciever != null ? !reciever.equals(order.reciever) : order.reciever != null) return false;
        if (startDate != null ? !startDate.equals(order.startDate) : order.startDate != null) return false;
        if (deliveryDate != null ? !deliveryDate.equals(order.deliveryDate) : order.deliveryDate != null) return false;
        if (comment != null ? !comment.equals(order.comment) : order.comment != null) return false;
        if (status != null ? !status.equals(order.status) : order.status != null) return false;
        if (cargoes != null ? !cargoes.equals(order.cargoes) : order.cargoes != null) return false;
        if (payment != null ? !payment.equals(order.payment) : order.payment != null) return false;
        if (orderWaypoints != null ? !orderWaypoints.equals(order.orderWaypoints) : order.orderWaypoints != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id.intValue();
        result = 31 * result + (sender != null ? sender.hashCode() : 0);
        result = 31 * result + (reciever != null ? reciever.hashCode() : 0);
        result = 31 * result + (startDate != null ? startDate.hashCode() : 0);
        result = 31 * result + (deliveryDate != null ? deliveryDate.hashCode() : 0);
        result = 31 * result + (comment != null ? comment.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        result = 31 * result + (cargoes != null ? cargoes.hashCode() : 0);
        result = 31 * result + (payment != null ? payment.hashCode() : 0);
        result = 31 * result + (orderWaypoints != null ? orderWaypoints.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Order{");
        sb.append("id=").append(id);
        sb.append(", sender='").append(sender.toString()).append('\'');
        sb.append(", reciever='").append(reciever.toString()).append('\'');
        sb.append(", startDate=").append(startDate);
        sb.append(", deliveryDate=").append(deliveryDate);
        sb.append(", comment=").append(comment);
        sb.append(", status=").append(status);
        sb.append(", cargoes=").append(cargoes);
        sb.append(", payment=").append(payment);
        sb.append(", orderWaypoints=").append(orderWaypoints);
        sb.append('}');
        return sb.toString();
    }
}
